package com.google.android.daca.types;

import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;


public class Poll implements Parcelable {
	private String pollID;
    //protected GregorianCalendar latestChange;
    protected PollType type;
    //protected Extensions extensions;
    protected Boolean hidden;
    //protected Boolean writeOnce;
    //protected Boolean requireAddress;
    //protected Boolean requireEMail;
    //protected Boolean requirePhone;
    //protected Boolean byInvitationOnly;
    protected Integer levels;
    protected States state;
    protected String title;
    protected String description;
    protected Initiator initiator;
    protected List<Option> options;
    protected List<Participant> participants;
//    protected CommentsType comments;
    
	public static final Parcelable.Creator<Poll> CREATOR
	= new Parcelable.Creator<Poll>() {
		public Poll createFromParcel(Parcel in) {
			return new Poll(in);
		}

		public Poll[] newArray(int size) {
			return new Poll[size];
		}
	};
    
    public Poll() {
    	type = PollType.TEXT;
    	state = States.OPEN;
    	hidden = false;
    	levels = 2;
    	description = "";
    }

    public Poll(Parcel in) {
    	super();
    	//ClassLoader loader = getClass().getClassLoader();
    	this.pollID = in.readString();
    	this.type = PollType.fromValue(in.readString());
    	this.hidden = (Boolean) in.readValue(Boolean.class.getClassLoader());
    	this.levels = in.readInt();
    	this.state = States.fromValue(in.readString());
    	this.title = in.readString();
    	this.description = in.readString();
    	this.initiator = in.readParcelable(Initiator.class.getClassLoader());
    	this.options = (ArrayList<Option>) in.readSerializable();
    	this.participants = in.createTypedArrayList(Participant.CREATOR);
    }


    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link PollType }
     *     
     */
    public PollType getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link PollType }
     *     
     */
    public void setType(PollType value) {
        this.type = value;
    }

    /**
     * Gets the value of the extensions property.
     * 
     * @return
     *     possible object is
     *     {@link Extensions }
     *     
     */
//    public Extensions getExtensions() {
//        return extensions;
//    }
//
//    /**
//     * Sets the value of the extensions property.
//     * 
//     * @param value
//     *     allowed object is
//     *     {@link Extensions }
//     *     
//     */
//    public void setExtensions(Extensions value) {
//        this.extensions = value;
//    }

    /**
     * Gets the value of the hidden property.
     * 
     * @return
     *     possible object is
     *     {@link Boolean }
     *     
     */
    public Boolean isHidden() {
        return hidden;
    }

    /**
     * Sets the value of the hidden property.
     * 
     * @param value
     *     allowed object is
     *     {@link Boolean }
     *     
     */
    public void setHidden(Boolean value) {
        this.hidden = value;
    }

    /**
     * Gets the value of the levels property.
     * 
     * @return
     *     possible object is
     *     {@link Integer }
     *     
     */
    public Integer getLevels() {
        return levels;
    }

    /**
     * Sets the value of the levels property.
     * 
     * @param value
     *     allowed object is
     *     {@link Integer }
     *     
     */
    public void setLevels(Integer value) {
        this.levels = value;
    }

    /**
     * Gets the value of the state property.
     * 
     * @return
     *     possible object is
     *     {@link States }
     *     
     */
    public States getState() {
        return state;
    }

    /**
     * Sets the value of the state property.
     * 
     * @param value
     *     allowed object is
     *     {@link States }
     *     
     */
    public void setState(States value) {
        this.state = value;
    }

    /**
     * Gets the value of the title property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTitle() {
        return title;
    }

    /**
     * Sets the value of the title property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTitle(String value) {
        this.title = value;
    }

    /**
     * Gets the value of the description property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getDescription() {
        return description;
    }

    /**
     * Sets the value of the description property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setDescription(String value) {
        this.description = value;
    }

    /**
     * Gets the value of the initiator property.
     * 
     * @return
     *     possible object is
     *     {@link Initiator }
     *     
     */
    public Initiator getInitiator() {
        return initiator;
    }

    /**
     * Sets the value of the initiator property.
     * 
     * @param value
     *     allowed object is
     *     {@link Initiator }
     *     
     */
    public void setInitiator(Initiator value) {
        this.initiator = value;
    }

    /**
     * Gets the value of the options property.
     * 
     * @return
     *     possible object is
     *     {@link OptionsType }
     *     
     */
    public List<Option> getOptions() {
        return options;
    }

    /**
     * Sets the value of the options property.
     * 
     * @param value
     *     allowed object is
     *     {@link OptionsType }
     *     
     */
    public void setOptions(List<Option> value) {
        this.options = value;
    }

    /**
     * Gets the value of the participants property.
     * 
     * @return
     *     possible object is
     *     {@link ParticipantsType }
     *     
     */
    public List<Participant> getParticipants() {
        return participants;
    }

    /**
     * Sets the value of the participants property.
     * 
     * @param value
     *     allowed object is
     *     {@link ParticipantsType }
     *     
     */
    public void setParticipants(List<Participant> value) {
        this.participants = value;
    }

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// We just need to write each field into the
		// parcel. When we read from parcel, they
		// will come back in the same order
		dest.writeString(pollID);
		dest.writeString(type.toString());
		dest.writeValue(hidden);
		dest.writeInt(levels);
		dest.writeString(state.toString());
		dest.writeString(title);
		dest.writeString(description);
		dest.writeParcelable(initiator, flags);
		dest.writeSerializable((ArrayList<Option>) options);
		dest.writeTypedList(participants);
	}

	/**
	 * @return the pollID
	 */
	public String getPollID() {
		return pollID;
	}

	/**
	 * @param pollID the pollID to set
	 */
	public void setPollID(String pollID) {
		this.pollID = pollID;
	}
}
